<template>
  <el-dropdown :hide-on-click="false" :show-timeout="100" trigger="click">
    <el-button plain>
      {{ platforms | toChinese(platforms) }}
      <i class="el-icon-caret-bottom el-icon--right" />
    </el-button>
    <el-dropdown-menu slot="dropdown" placement="bottom" class="no-border">
      <el-radio-group v-model="platforms">
        <el-radio-button v-for="item in platformsOptions" :key="item.key" :label="item.key">
          {{ item.name }}
        </el-radio-button>
      </el-radio-group>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
var thisBak;
export default {
  filters: {
    toChinese(key) {
      if (thisBak.flag == 'notice') {
        switch (key) {
          case '0':
            return '请选择动态类型';
            break;
          case '1':
            return '公告';
            break;
          case '2':
            return '动态';
            break;
          case '3':
            return '捐赠';
            break;
        }
      } else if (thisBak.flag == 'events') {
        switch (key) {
          case '0':
            return '请选择事件类型';
            break;
          case '1':
            return '讲座';
            break;
          case '2':
            return '展览';
            break;
          case '3':
            return '活动';
            break;
        }
      }
    }
  },
  props: {
    platformsOptionList: {
      type: Array
    },
    eflag: {
      required: true
    },
    value: {
      required: true,
      default: () => '0'
    }
  },
  data() {
    return {
      platformsOptions: [],
      flag: ''
    };
  },
  computed: {
    platforms: {
      get() {
        return this.value;
      },
      set(val) {
        this.$emit('input', val);
      }
    }
  },
  beforeCreate() {
    thisBak = this;
  },
  mounted() {
    const _this = this;
    const props = { ..._this._props };
    this.platformsOptions = props['platformsOptionList'];
    this.flag = props['eflag'];
    console.log(props, 'props.......');
  }
};
</script>
